﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PServiceBus.MessageProxy;
using PServiceBus.Transports;

namespace LoanMessages {

    [ESBProxyService]
    public interface ILoanService {

        [ESBRequest(typeof(LoanRequest), isRequestClass: true)]
        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "1111")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        LoanResponse GetLoan(LoanRequest request);

        [ESBRequest(typeof(BankQuoteRequest), isRequestClass: true)]
        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "2222")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        BankQuoteReply GetBankQuote(BankQuoteRequest request);

        [ESBRequest(typeof(CreditBureauRequest), isRequestClass: true)]
        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "3333")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        CreditBureauReply GetCredit(CreditBureauRequest request);

        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "7777")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        [ESBListener(typeof(BankQuoteReply), "receiver1")]
        void ReceiveBankQuote(Action<BankQuoteReply> action, Func<Exception, bool> error);


        [ESBTransport(typeof(TcpTransport))]
        [ESBTransportParam("Port", "8888")]
        [ESBTransportParam("IPAddress", "127.0.0.1")]
        [ESBListener(typeof(CreditBureauReply), "receiver2")]
        void ReceiveCreditQuote(Action<CreditBureauReply> action, Func<Exception, bool> error);

        [ESBRequest(typeof(BankQuoteRequest), isRequestClass: true)]
        void SendBankQuote(BankQuoteRequest msg);

        [ESBRequest(typeof(CreditBureauRequest), isRequestClass: true)]
        void SendCreditRequest(CreditBureauRequest msg);
    }
    
}
